MergeDocuments(String[],String) Method
In This Topic
Merge several PDF documents according to their file paths stored in the input parameter. All pages of the source documents are cloned one by one to the destination document in that order how they are stored in the input parameter. The resulting PDF document is saved to a file path you have specified. If the specified file already exists, it will be overwritten.
If the first PDF document in the list (specified by the first object in the input parameter) is PDF/A compliant, the resulting document will also be PDF/A compliant. The conformance level and version of the merged document will be PDF/A-1b regardless of the original conformance of the first source document.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents. The feature is available in both 32-bit and 64-bit mode by default.
Syntax
'Declaration
Public Overloads Function MergeDocuments( _
ByVal () As String, _
ByVal As String _
) As GdPictureStatus
public GdPictureStatus MergeDocuments(
string[] ,
string
)
public function MergeDocuments(
: Stringarray of;
: String
): GdPictureStatus;
public function MergeDocuments(
: String[],
: String
) : GdPictureStatus;
public: GdPictureStatus MergeDocuments(
string*[]* ,
string*
)
public:
GdPictureStatus MergeDocuments(
array<String^>^ ,
String^
)
Parameters
- SrcDocPath
- An array of strings defining the file paths of all the PDF documents you want to merge.
- DstDoc
- The file path of the destination PDF document.
Please ensure that the destination file path differs from all source file paths.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
How to merge 3 PDF documents using their file paths into a PDF document specified by its file path.
Dim arPDF As String() = New String(2) {}
arPDF(0) = "test1.pdf"
arPDF(1) = "test2.pdf"
arPDF(2) = "test3.pdf"
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.MergeDocuments(arPDF, "test_merged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments")
Else
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments")
End If
End Using
string[] arPDF = new string[3];
arPDF[0] = "test1.pdf";
arPDF[1] = "test2.pdf";
arPDF[2] = "test3.pdf";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.MergeDocuments(arPDF, "test_merged.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments");
}
else
{
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments");
}
}
Example
How to merge 3 PDF documents using their file paths into a PDF document specified by its file path.
Dim arPDF As String() = New String(2) {}
arPDF(0) = "test1.pdf"
arPDF(1) = "test2.pdf"
arPDF(2) = "test3.pdf"
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.MergeDocuments(arPDF, "test_merged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments")
Else
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments")
End If
End Using
string[] arPDF = new string[3];
arPDF[0] = "test1.pdf";
arPDF[1] = "test2.pdf";
arPDF[2] = "test3.pdf";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.MergeDocuments(arPDF, "test_merged.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments");
}
else
{
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments");
}
}
See Also